$(document).ready(function(){
$('#sendBtn').on('click', function () {
    //console.log('呵呵哈哈哈')
    $('#result').html("<h1>法条匹配结果</h1>")
    var content = $('#content').val();
    var type = $('#type').val();
    var nums = $("#nums").val();
    var embedding_type = $('#embedding_type').val()
    setTimeout(answers(content,type,nums,embedding_type), 1000);

})
});

function answers(content,type,nums,embedding_type) {

    $.ajax({
        url: "/result/net",
        type: "post",
        dataType: "json",
        data: $('#form').serialize(),
        success: function (data) {
            //console.log(data)
            var answer = '<h2>文本类别为:</h2>'+type+'<br><h2>匹配结果为</h2>'
            +'<table border="1"><tr>'
            if(embedding_type == '案由匹配'){
                answer += ' <th>案由DM</th><th>案由名称</th>'
            }else{
                answer += ' <th>匹配条数</th><th>匹配内容</th>'
            }
            if(embedding_type == '关键词匹配'){
                answer += '<th>关键词</th>'
            }else{
                answer += '<th>相似度</th>'
            }
            answer += '</tr>'
            for(i=0;i<data.result.length;i++){
                answer += '<tr><td>'+data.result[i].num+'</td><td>'+data.result[i].result+'</td>'
                //console.log(embedding_type)
                if(embedding_type == '关键词匹配'){
                    answer += '<td>'+ data.result[i].words.toString()+'</td>'
                }else{
                    answer += '<td>'+ data.result[i].cos+'</td>'
                }
                answer += '</tr>'

            }
//            console.log(answer)



            $('#result').append(answer);
        }
    });
}



